package com.zycfc.zsf.boot.util.json;

import com.google.gson.*;
import com.google.gson.internal.*;
import java.util.*;
import java.io.*;
import com.google.gson.stream.*;
import org.slf4j.*;

public class MapTypeAdapter extends TypeAdapter<Object>
{
    private static final Logger log;
    
    public Object read(final JsonReader in) throws IOException {
        final JsonToken token = in.peek();
        switch (token) {
            case BEGIN_ARRAY: {
                final List<Object> list = new ArrayList<Object>();
                in.beginArray();
                while (in.hasNext()) {
                    list.add(this.read(in));
                }
                in.endArray();
                return list;
            }
            case BEGIN_OBJECT: {
                final Map<String, Object> map = (Map<String, Object>)new LinkedTreeMap();
                in.beginObject();
                while (in.hasNext()) {
                    map.put(in.nextName(), this.read(in));
                }
                in.endObject();
                return map;
            }
            case STRING: {
                return in.nextString();
            }
            case NUMBER: {
                final double dbNum = in.nextDouble();
                if (dbNum > 9.223372036854776E18) {
                    return dbNum;
                }
                final long lngNum = (long)dbNum;
                if (dbNum == lngNum) {
                    return lngNum;
                }
                return dbNum;
            }
            case BOOLEAN: {
                return in.nextBoolean();
            }
            case NULL: {
                in.nextNull();
                return null;
            }
            default: {
                MapTypeAdapter.log.info("\u6682\u4e0d\u652f\u6301\u7c7b\u578b");
                throw new IllegalStateException();
            }
        }
    }
    
    public void write(final JsonWriter out, final Object value) throws IOException {
    }
    
    static {
        log = LoggerFactory.getLogger((Class)MapTypeAdapter.class);
    }
}
